<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%
//不读取缓存页面。强制浏览器重新访问服务器下载页面。
/* response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0); */

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>内容输入/编辑</title>
<base href="${basePath}"/>
<style type="text/css">
body {font-family: Arial, Helvetica, sans-serif; font-size:12px; text-align:center;}
a { text-decoration: none;}
#all {widht:100%; text-align:center; margin:auto;height:99%;overflow:hidden; border: 0px solid #FF0000;}
#main {width: 96%; line-height: 1.8; margin:auto; border:1px #ccc dashed; text-align: left; text-indent: 2em;}

.hr0{ height:1px;border:none;border-top:1px dashed #1E90FF;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="javascript/ajaxfileupload.js"></script>
<script type="text/javascript" src="${basePath}ckeditor/ckeditor.js"></script>
<script type="text/javascript">
jQuery(function($){
	CKEDITOR.replace('content',{
		language : 'zh-cn',//简体中文   
		width : "99%", //宽度
		height :"390", //高度
		//工具栏是否可以被收缩,bug：收缩后宽度会变化
		//toolbarCanCollapse:true, 
		toolbar : //工具栏设置               随便取舍
		[
				[ 'Source', 'Maximize', '-', 'Save', 'NewPage',
						'Preview', '-', 'Templates' ],
				[ 'Cut', 'Copy', 'Paste', 'PasteText',
						'PasteFromWord' ],
				[ 'Undo', 'Redo', '-', 'Find', 'Replace', '-', ,
						'Table', 'HorizontalRule', '-',
						'SelectAll', 'RemoveFormat' ],
				'/',
				[ 'Bold', 'Italic', 'Underline', 'Strike', '-',
						'Subscript', 'Superscript' ],
				[ 'NumberedList', 'BulletedList', '-', 'Outdent',
						'Indent', 'Blockquote' ],
				[ 'JustifyLeft', 'JustifyCenter', 'JustifyRight',
						'JustifyBlock' ],
				[ 'Link', 'Unlink', 'Anchor' ],
				[ 'Image', 'Flash', 'Smiley', 'SpecialChar',
						'PageBreak' ],
				[ 'Styles', 'Format', 'Font', 'FontSize' ],
				[ 'TextColor', 'BGColor' ] ]
	});
	
	
});


function ajaxFileUpload() {
	$("#loading").ajaxStart(function() {
		$(this).show();
	})//开始上传文件时显示一个图片
	.ajaxComplete(function() {
		$(this).hide();
	});//文件上传完成将图片隐藏起来

	$.ajaxFileUpload({
		url : 'content/upload.htm',//用于文件上传的服务器端请求地址
		secureuri : false,//一般设置为false
		fileElementId : 'file',//文件上传空间的id属性  <input type="file" id="file" name="file" />
		dataType : 'json',//返回值类型 一般设置为json
		success : function(data, status) //服务器成功响应处理函数
		{
			//alert(data.fileFileName);
			$("#coverPic").attr("src","upload/"+data.fileFileName);
			$("#pic").val(data.fileFileName);
			alert(data.message);//从服务器返回的json中取出message中的数据,其中message为在struts2中action中定义的成员变量
			
			if (typeof (data.error) != 'undefined') {
				if (data.error != '') {
					alert(data.error);
				} else {
					alert(data.message);
				}
			}
		},
		error : function(data, status, e)//服务器响应失败处理函数
		{
			alert(e);
		}
	});
	return false;
}
</script>
</head>
<body>
<strong>修改文章</strong>
<hr class="hr0" />
<div id="all" >

<form action="content/content_submit.htm" method="post">    
  <!--  <font size="3"><strong>封面</strong></font>  -->
<table align="center">
	<tr>
		<td>
		<img src="images/loading.gif" id="loading" style="display: none;width:20px;height: 20px; ">上传封面图片(<font color="red">200 x 280</font>)<br/>
	    <input type="file" id="file" name="file" style="width: 600px; left: 3px;" /> &nbsp;&nbsp;
	    <input type="button" value="上传封面图片 " onclick="return ajaxFileUpload();">
		</td>
		<td rowspan="2">
			<img id="coverPic" alt="" src="upload/${model.pic}" width="200" height="280"/>
		</td>
	</tr>
	<tr>	
		<td>
			<input id="pic" type="hidden" name="pic" value="${model.pic}"/>
			简介：<br/><textarea name="precontent" rows="8" cols="89" style="height:99%;">${model.precontent}</textarea>
		</td>
	</tr>
</table>
    
<hr class="hr0" /><!-- 分割线 -->

<font size="3"><strong>内容</strong></font>

<table height="100%" border="0">
<tr><td colspan="2" align="left">
标题：<input type="text" name="title" value="${model.title}"/>
语言:<select name="langId"><option value="1" <c:if test="${model.langId==1}">selected="selected"</c:if> >中文</option><option value="2" <c:if test="${model.langId==2}">selected="selected"</c:if>>英文</option></select>
栏目：<select name="underId"><option value="1" <c:if test="${model.underId==1}">selected="selected"</c:if> >栏目一</option><option value="2" <c:if test="${model.underId==2}">selected="selected"</c:if>>栏目二</option></select>
是否在导航栏显示：<input type="checkbox" name="isTitle" value="1" <c:if test="${model.isTitle==1}">checked="checked"</c:if> />
是否在首页滑动显示：<input type="checkbox" name="isAdv" value="1" <c:if test="${model.isAdv==1}">checked="checked"</c:if> />
是否有PDF：<input type="checkbox" name="havePdf" value="1" <c:if test="${model.havePdf==1}">checked="checked"</c:if> />
</td></tr>
<tr><td>

<textarea id="content" name="content" rows="60" cols="50" style="height:99%;">${model.content}</textarea><!--  -->

</td><td valign="top">

<select name="belongto" multiple="multiple" style= "height:500px;width:230px;margin-left:0px; ">
<c:choose>
	<c:when test="${not empty choosepro}">
		<c:forEach items="${choosepro}" var="cp" varStatus="status">
			<optgroup label="${cp.name}">
				<c:choose>
					<c:when test="${not empty cp.subselection}">
						<c:forEach items="${cp.subselection}" var="cpss" varStatus="status">
							<option value="${cpss.name}" <c:if test="${fn:contains(model.belongto,cpss.name)}">selected="selected"</c:if>>${cpss.name}</option>
							</c:forEach>
						</c:when>
					</c:choose>
				</optgroup>
			</c:forEach>
		</c:when>
	</c:choose>
</select>

</td></tr>
<tr><td colspan="2"><input type="submit" value="   提 交   " style="width: 100px;"/></td></tr>
</table>
</form>
</div>



</body>
</html>